module df_dt
use technical
use cdata
!use timestep
implicit none
public 
real :: harmonic_omega=0.
namelist /model_pars/ &
    harmonic_omega
contains
!****************************************************
subroutine ini_rhs(model,input_file)
character(len=labellen) :: model
integer :: input_file 
select case(model)
  case('harmonic') 
   if(ndim .ne. 2) & 
        call fatal_error("ini_rhs","model harmonic should have ndim=2")
   call read_model_pars(input_file)
   if(harmonic_omega.eq.0) & 
       call fatal_error("ini_rhs","model harmonic but omega=0")
   !call read_initcond(input_file)
case('none')
   call fatal_error("models:eval_rhs","no model selected, model="//trim(model))
case default
   call fatal_error("models:eval_rhs","no model found, model="//trim(model))
!
end select
end subroutine ini_rhs
!****************************************************
subroutine eval_rhs(x,time,dx)
implicit none
character(len=labellen) :: model
real,dimension(ndim) :: x,dx
real :: time
intent(in) :: x,time
intent(out) :: dx
!----------------------------------
select case(model)
case('harmonic'); call harmonic (x,dx)
case default
   call fatal_error("models:eval_rhs","no model found"//trim(model))
!
end select
!----------------------
end subroutine
!*****************************************
subroutine read_model_pars(file_number)
implicit none
integer :: file_number
integer :: ierr
!<reads in the namelist of model parameters !
  read(file_number,NML=model_pars, IOSTAT=ierr)
!  rewind(file_number)
  if(ierr/=0) call fatal_error('read_model_pars','problem with reading model_pars')
end subroutine 
!*****************************************
subroutine harmonic(x,dx)
implicit none
real,dimension(ndim) :: x,dx
dx(1)=x(2)
dx(2)=-(harmonic_omega**2)*x(1)
end subroutine

!============================================!
end module df_dt
